package com.github.ghsea.sso.client.config;

import com.github.ghsea.sso.client.security.cas.CasFilterExt;
import com.github.ghsea.sso.client.security.cas.LogoutFilterExt;
import com.github.ghsea.sso.client.security.permission.PermissionManagerDelegate;
import com.github.ghsea.sso.client.security.permission.UserManagerDelegate;
import com.github.ghsea.sso.client.security.shiro.DefaultFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author guhai
 */
@Configuration
@EnableShiro
public class ShiroCasConfiguration {

    @Bean
    public PermissionManagerDelegate permissionManagerDelegate(){
        return new PermissionManagerDelegate();
    }

    @Bean
    public UserManagerDelegate userManagerDelegate(){
        return new UserManagerDelegate();
    }

    @Bean
    public FilterRegistrationBean cancelDefaultFilter(DefaultFilter filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean(filter);
        registration.setEnabled(false);
        return registration;
    }


    @Bean
    public FilterRegistrationBean cancelLogoutFilterExt(LogoutFilterExt filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean(filter);
        registration.setEnabled(false);
        return registration;
    }

    @Bean
    public FilterRegistrationBean cancelCasFilterExt(CasFilterExt filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean(filter);
        registration.setEnabled(false);
        return registration;
    }


}
